package cn.wolfcode.p2p.service;

import cn.wolfcode.p2p.business.service.IBidRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public	class	SimpleTask	{
        @Autowired
        private IBidRequestService bidRequestService;


        /**
         * 每秒从队列里查待发标对象,拿出已经发标时间到了的,改状态,删队列里的这个
         */
        @Scheduled(cron = "*/1 * * * * ?")
        public void simpleTask() {
                //每秒去查队列

                bidRequestService.checkPublishBidRequestForQueue();

        }

        /**
         *每隔1分钟查数据库,把待发标的都加进队列,要去重
         */
        @Scheduled(cron = "*/59 * * * * ?")
        public void simpleTask1() {
                //每30秒去數據庫查,發佈時間小於或者等於當前系統時間的,修改狀態為發標中
                bidRequestService.selectPublishBidRequestToQueue();
        }
}